package com.example.springboot.controller;

import com.example.springboot.enums.ServiceEnum;
import com.example.springboot.factorys.BaseServiceFactory;
import com.example.springboot.service.BaseService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 注入ListService
 */
@RestController
public class BaseServiceTestController {

    private final BaseServiceFactory baseServiceFactory;

    public BaseServiceTestController(BaseServiceFactory baseServiceFactory) {
        this.baseServiceFactory = baseServiceFactory;
    }

    @GetMapping("/api/test/service/list")
    public String getString(String serviceEnum){

        ServiceEnum se = ServiceEnum.findBy(serviceEnum);
        if(se == null){
            return "不存在服务类型";
        }
        BaseService by = baseServiceFactory.findBy(se);
        return by.business();
    }

}
